package J0121;

import java.util.PriorityQueue;

public class minK {
    public int[] smallestK(int[] arr, int k) {
        PriorityQueue<Integer> pt = new PriorityQueue<>();
        for (int i = 0; i < arr.length; i++) {
            pt.offer(arr[i]);
        }
        int[] tmp = new int[k];
        for (int i = 0; i < k; i++) {
            tmp[i] = pt.poll();
        }
        return tmp;
    }
}
